package cn.ldh.controller;

import cn.ldh.domain.User;
import cn.ldh.fallback.FallbackOrders;
import cn.ldh.feignclient.UserFeignclient;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private UserFeignclient userFeignclient;

    @GetMapping("/getById/{id}")
    //@SentinelResource(value = "order-server" ,fallback = "fallbackOrder",fallbackClass = FallbackOrders.class)
    public User getById(@PathVariable("id") Long id){

        return userFeignclient.getById(id);

    }

//    public User fallbackOrder(@PathVariable("id") Long id, Throwable t){
//        t.printStackTrace();
//        return new User(-1L,"熔断触发","熔断了");
//
//    }
}
